// $Id: server.h 82 2011-04-24 08:31:42Z cedric.shih@gmail.com $
/*
 * Copyright (C) 2010 Cedric Shih <cedric.shih@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef NIOSERVER_H_
#define NIOSERVER_H_

#ifdef __cplusplus
extern "C" {
#endif

struct niochannel;

typedef struct niochannel *(*niochannel_create_cb)(
		struct niosocket *socket, void *arg);

typedef void (*niochannel_release_cb)(struct niochannel *channel, void *arg);

struct niochannel_factory {
	niochannel_create_cb create;
	niochannel_release_cb release;
};

struct nioserver;

struct nioreactor;

struct nioserver *nioserver_new(struct nioreactor *reactor,
		struct niochannel_factory *factory, void *cbarg);

void nioserver_free(struct nioserver *server);

struct in_addr;

int nioserver_bind(struct nioserver *server,
		struct in_addr *address, unsigned short port, int backlog);

int nioserver_unbind(struct nioserver *server);

#ifdef __cplusplus
}
#endif

#endif /* NIOSERVER_H_ */
